import java.io.*;
import java.util.*;

class Item{

	String itemCode;
	String itemName;
	float price;
	
	public Item(String a,String b,float c){
		itemCode=a;
		itemName=b;
		price=c;
		
	}
	public void setItemCode(String a){
		itemCode=new String(a);
	}
	
	public void setItemName(String a){
		itemName=new String(a);
	}
	
	public void setPrice(float a){
		price=a;
	}
	
	
	public String getItemCode(){
		return itemCode;
	}
	
	public String getItemName(){
		return itemName;
	}
	
	public float getPrice(){
		return price;
	}
	
}

class Bill{
	ArrayList<Item> l=new ArrayList<Item>();
	
	public void addItem(String itemCode,String itemName,float price){
		l.add(new Item(itemCode,itemName,price));
	}
	
	public void deleteItem(int indexno){
		l.remove(indexno-1);
	}
	
	public void displayBill(){
		String s="";
		for(Item i:l) {
                        s=s+i+"\n";
		}
		System.out.println(s);
		
	}
	
	public int noOfItems(){
		return l.size();
	}
}

class Main
{	
	public static void main(String[] args){
		Bill b1=new Bill();
		int i=0,op;
		String ch="yes",itemCode,itemName;
		float total=0,price;
		Scanner sc=new Scanner(System.in);
		System.out.println("Menu\n1.Add Items\n2.Delete Items\n3.Generate Bill\n4.Exit");
		System.out.println("Enter option");
		op=sc.nextInt();
		while(true){
		
			switch(op){
				case 1:
					while(ch.equals("yes")){
					System.out.println("Enter Code");
					itemCode=sc.next();
					System.out.println("Enter Item Name");
					itemName=sc.next();
					System.out.println("Enter price");
					price=sc.nextFloat();
					System.out.println("Want to add a new item");
					ch=sc.next();
					b1.addItem(itemCode,itemName,price);		
					}
					break;
			
				case 2:
					while(ch.equals("yes")){
					System.out.println("Enter index number");
					b1.deleteItem(sc.nextInt());
					}
					break;
				
				case 3:
					System.out.println("CODE\tNAME\tPRICE");
					b1.displayBill();
					b1.noOfItems();
					break;
			
				case 4:System.exit(0);
					break;
				
			}
			System.out.println("Enter chance");
			ch=sc.next();
	
		}		
	}
}
